<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>2.ajax_status.html</title>
    <style>
        #content{
            width: 300px;
            height: 200px;
            background: aquamarine;
        }
    </style>
</head>
<body>

<div id="content">

</div>
<button id="btn">发送</button>

<script>
    let content =document.getElementById("content");
    let btn =document.getElementById("btn");
    btn.onclick=()=>{
       const xhr = new XMLHttpRequest();
       /*注意回调要写在这不然无法获取状态1*/
        /*xhr*/
       xhr.onreadystatechange=()=>{
           console.log(xhr.readyState);
       };
       xhr.open("GET","./");
       xhr.send();

    }
</script>

</body>
</html>